package com.java.huxb.backend.cinema.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.java.huxb.backend.cinema.dao.entity.MoocCinemaT;
import com.java.huxb.backend.cinema.service.CinemaServiceAPI;
import com.java.huxb.backend.utils.exception.CommonServiceException;
import com.java.huxb.backend.utils.vo.BasePageVO;
import com.java.huxb.backend.utils.vo.BaseResponseVO;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author huxb
 * @date 2020/1/29 0029 下午 5:58
 */
@RestController
@RequestMapping("/cinema")
public class CinemaController {
    @Autowired
    private CinemaServiceAPI cinemaServiceAPI;

    @RequestMapping("/list")
    public BaseResponseVO findPageBy(BasePageVO basePageVO) {
        IPage<MoocCinemaT> page = cinemaServiceAPI.findPageBy(new Page(basePageVO.getNowPage(), basePageVO.getPageSize()));
        return BaseResponseVO.success(page);
    }

    @RequestMapping("/addOrEdit")
    public BaseResponseVO addOrEdit (MoocCinemaT moocCinemaT) throws CommonServiceException {
       if (moocCinemaT.getUuid() == null) {
           cinemaServiceAPI.addCinema(moocCinemaT);
       } else {
           cinemaServiceAPI.editCinema(moocCinemaT);
       }
        return BaseResponseVO.success();
    }

}
